home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2005 November
/
WNnov2005.iso
/
Windows
/
Indispensables
/
Movie Collection
/
MovieCollection5403.exe
/
{app}
/
php5
/
films.php
< prev
next >
Wrap
PHP Script
|
2005-03-03
|
3KB
|
105 lines
<?php
include_once('sql.class.php');
include_once('replace.class.php');
include_once('tools.class.php');
include_once('sqlfilter.class.php');
$mcsql= new TmcSql();
$doc = new DOMDocument();
$node = createDataPacket($doc);
$datapacket=$node;
$node = $doc->createElement('columns');
$rootnode = $node;
// Colonnes
$odocCols = new DOMDocument();
$odocCols->load('columns.xml');
$oxpathCols = new DOMXPath($odocCols);
$oCols= array();
$res = $oxpathCols->query('//datapacket/columns/column');
$i=0;
foreach ($res as $nodeCols)
{
$nom = $nodeCols->getAttribute('nom');
$caption = $nodeCols->getAttribute('caption');
$oCols[$i]= $nom;
$node = $doc->createElement('column');
$node->setAttribute("nom", $nom);
$node->setAttribute("caption", $caption);
$rootnode->appendChild($node);
$i++;
}
$datapacket->appendChild($rootnode);
// Liste des films
$node = $doc->createElement('films');
$rootnode = $node;
// Recherche
$filter = new TSqlFilter('select idx, '.implode(', ', $oCols).' from t_film');
$selectCollection = $_POST["selectCollection"];
if ((!isset($selectCollection)) or ($selectCollection==''))
$selectCollection=-1;
if ($selectCollection!=-1)
$filter->addFilter("idcollection=$selectCollection");
$selectCategorie = $_POST["selectCategorie"];
if ((!isset($selectCategorie)) or ($selectCategorie==''))
$selectCategorie=-1;
if ($selectCategorie!=-1)
$filter->addFilter("idcategorie=$selectCategorie");
$textMots = $_POST["textMots"];
if (isset($textMots) and ($textMots!=''))
{
$mots = $textMots;
$mots = str_replace(" ", "+", $mots);
$mots = str_replace("+", " ", $mots);
$tab_mots = explode(" ", $mots);
for ($i=0; $i<count($tab_mots); $i++)
{
$search = Trim($tab_mots[$i]);
if ($search!="")
{
$filter->addFilter("nom like '%$search%'");
//echo("nom like '%$search%'<br />");
}
}
}
$tab = $mcsql->openSql($filter->getSql());
foreach ($tab as $key => $row)
{
$node = $doc->createElement('film');
foreach ($oCols as $id_col => $val)
{
$nom = $nodeCols->getAttribute('nom');
$node->setAttribute($val, utf8_encode($row[$val]));
}
$node->setAttribute('idx', $row['idx']);
$rootnode->appendChild($node);
}
$datapacket->appendChild($rootnode);
$xsl = new DomDocument;
$xsl->load('./films.xsl');
$xsl_srce = $xsl->saveXML();
$replace = new TmcXslReplace($xsl_srce);
$xsl_srce = $replace->processReplace();
$xsl->loadxml($xsl_srce);
$proc = new xsltprocessor();
$proc->importStyleSheet($xsl); // Importation des rΦgles XSL
echo $proc->transformToXML($doc); // Transformation
//print $doc->saveXML();
?>